<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="PaseListForm" target="_blank">

        <p:panel header="#{myBundle.ListPaseTitle}">
            <p:contextMenu id="PaseDataTableContextMenu" for="datalist">  
                <p:menuitem value="#{myBundle.Create}" onclick="document.getElementById('PaseListForm:createButton').click();" icon="ui-icon-plus"/>
                <p:menuitem value="#{myBundle.View}" onclick="document.getElementById('PaseListForm:viewButton').click();" icon="ui-icon-search"/>
                <p:menuitem value="#{myBundle.Edit}" onclick="document.getElementById('PaseListForm:editButton').click();" icon="ui-icon-pencil"/>
                <p:menuitem value="#{myBundle.Delete}" onclick="document.getElementById('PaseListForm:deleteButton').click();" icon="ui-icon-trash"/>
                <p:separator/>
                <p:menuitem value="#{myBundle.PaseMenuItem_expediente}" icon="ui-icon-search"  actionListener="#{paseController.prepareExpediente}" update=":ExpedienteViewForm" oncomplete="ExpedienteViewDialog.show()" disabled="#{empty paseController.selected.expediente}"/>  
                <p:menuitem value="#{myBundle.PaseMenuItem_departamentoOrigen}" icon="ui-icon-search"  actionListener="#{paseController.prepareDepartamentoOrigen}" update=":DepartamentoViewForm" oncomplete="DepartamentoViewDialog.show()" disabled="#{empty paseController.selected.departamentoOrigen}"/>  
                <p:menuitem value="#{myBundle.PaseMenuItem_departamentoDestino}" icon="ui-icon-search"  actionListener="#{paseController.prepareDepartamentoDestino}" update=":DepartamentoViewForm" oncomplete="DepartamentoViewDialog.show()" disabled="#{empty paseController.selected.departamentoDestino}"/>  

                <p:menuitem value="Generar Remito" onclick="document.getElementById('PaseListForm:remitoButton').click();" icon="icon-report" />

            </p:contextMenu>
            <p:dataTable id="datalist"
                         value="#{expedienteBean.pases}"
                         var="item"
                         rowKey="#{item.id}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="10,20,30,40,50"
                         selectionMode="single"
                         selection="#{expedienteBean.paseSelected}">

                <p:ajax event="rowSelect"   update=":PaseListForm:createButton :PaseListForm:viewButton :PaseListForm:editButton :PaseListForm:deleteButton :PaseListForm:PaseDataTableContextMenu" listener="#{paseController.resetParents}"/>
                <p:ajax event="rowUnselect" update=":PaseListForm:createButton :PaseListForm:viewButton :PaseListForm:editButton :PaseListForm:deleteButton :PaseListForm:PaseDataTableContextMenu" listener="#{paseController.resetParents}"/>
                <p:ajax event="rowDblselect" onsuccess="document.getElementById('PaseListForm:viewButton').click();"/>

                <p:column sortBy="#{item.expediente.id}" filterBy="#{item.expediente.id}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPaseTitle_expediente}"/>
                    </f:facet>
                    <h:outputText value="#{item.expediente.id}"/>
                </p:column>


                <p:column sortBy="#{item.departamentoOrigen.nombre}" filterBy="#{item.departamentoOrigen.nombre}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPaseTitle_departamentoOrigen}"/>
                    </f:facet>
                    <h:outputText value="#{item.departamentoOrigen.nombre}"/>
                </p:column>


                <p:column sortBy="#{item.departamentoDestino.nombre}" filterBy="#{item.departamentoDestino.nombre}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPaseTitle_departamentoDestino}"/>
                    </f:facet>
                    <h:outputText value="#{item.departamentoDestino.nombre}"/>
                </p:column>


<!--                <p:column sortBy="#{item.id}" filterBy="#{item.id}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPaseTitle_id}"/>
                    </f:facet>
                    <h:outputText value="#{item.id}"/>
                </p:column>-->

            <f:attribute name="expediente" value="#{expedienteController.selected}" />
            </p:dataTable>

            <p:commandButton id="createButton"                             icon="ui-icon-plus"   value="#{myBundle.Create}" actionListener="#{expedienteBean.pasePrepareCreate}" update=":PaseCreateForm" oncomplete="PF('PaseCreateDialog').show()" />
            
            <p:commandButton id="remitoButton"                             icon="icon-report" ajax="false"  value="Generar Remito" action="#{expedienteBean.generarRemito()}" /> 
            <p:commandButton id="expedientesButton"                         value="Volver a expedientes" action="#{expedienteBean.volverAExpediente()}" /> 
            <a href="../../../../../../../AppData/Local/Temp/reloj-automatico_DisplayType_G_OrderId_PRICE-DESC_ItemTypeID_N.url"></a>
            <p:commandButton id="viewButton"   style="visibility: hidden;" icon="ui-icon-search" value="#{myBundle.View}" update=":PaseViewForm" oncomplete="PaseViewDialog.show()" disabled="#{empty expedienteBean.paseSelected}"/>
            <p:commandButton id="editButton"   style="visibility: hidden;"                            icon="ui-icon-pencil" value="#{myBundle.Edit}" update=":PaseEditForm" oncomplete="PaseEditDialog.show()" />
            <p:commandButton id="deleteButton" style="visibility: hidden;" icon="ui-icon-trash"  value="#{myBundle.Delete}" actionListener="#{expedienteBean.eliminarPase}" update=":growl,datalist" />
       
            
        </p:panel>
    </h:form>

</ui:composition>